package com.zline.foodraise.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.zline.foodraise.R;
import com.zline.foodraise.entity.ProjectBean;
import com.zline.foodraise.util.ImageUtil;
import com.zline.foodraise.view.RaiseProductCardItem;
import com.zline.foodraise.view.RaiseProductCardItem_;
import com.zline.foodraise.view.RecyclerViewLoadMore_;

import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

/**
 * Created by heshantao on 15/7/2.
 * 筹店中的众筹商品列表
 */
@EBean
public class RaiseProductCardAdapter extends LoadRecyclerBaseAdapter<ProjectBean, RaiseProductCardItem> {
    private static final String LOG_TAG = RaiseProductCardAdapter.class.getSimpleName();
    @RootContext
    Context cxt;
    @Bean
    ImageUtil imageUtil;
    DisplayImageOptions options;

    @Override
    protected RaiseProductCardItem onCreateItemView(ViewGroup parent, int viewType) {
        return RaiseProductCardItem_.build(cxt);
    }

    @Override
    protected BottomWrapper onCreateBottomView(ViewGroup parent, int viewType) {
        return new BottomWrapper(RecyclerViewLoadMore_.build(cxt));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof ContentWrapper) {
            RaiseProductCardItem view = (RaiseProductCardItem) ((ContentWrapper) holder).getView();
            ProjectBean projectBean = (ProjectBean) arrys.get(position);
            if (options == null) {
                options = imageUtil.
                        getDisplayImageOptions(R.mipmap.default_product_icon,
                                R.mipmap.default_product_icon, R.mipmap.default_product_icon);
            }
            view.bind(projectBean,position,options);
            view.setRecycleItemListener(itemClicked);
        }

    }

}
